package yuekao9.ods;

import yuekao6.util.KafkaUtil;
import yuekao6.util.MyDeserializationSchemaFunction;
import com.alibaba.ververica.cdc.connectors.mysql.MySQLSource;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import yuekao9.util.JsonDebeziumDeserializationUtil;

public class MockData {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        //(1)生产业务数据创建数据库运行sql文件tms2023.sql，运行tms-mock****.jar生产业务数据（10分）
        SourceFunction<String> sourceFunction = MySQLSource.<String>builder()
                .hostname("hadoop-single")
                .port(3306)
                .databaseList("yk9") // monitor all tables under inventory database
                .username("root")
                .password("root")
                .deserializer(new MyDeserializationSchemaFunction()) // converts SourceRecord to String
                .build();


        DataStreamSource<String> streamSource = env.addSource(sourceFunction);
//        streamSource.print();

        streamSource.addSink(KafkaUtil.kafkaSink("tms_ods"));


        env.execute();
    }
}
